<?php

if(!defined('IN_UCHOME')) {
	exit('Access Denied');
}

$list = array();

$id = empty($_GET['id'])?0:intval($_GET['id']);
$_GET['fc'] = empty($_GET['fc'])?'jobring':$_GET['fc'];


if(!empty($_GET['id'])){
	$sql = "SELECT * FROM ".tname('info_message')." where touid =".$space['uid']." and infoid = ".$id." ORDER BY dateline desc" ;
	$query = $_SGLOBAL['db']->query($sql);

	while($value = $_SGLOBAL['db']->fetch_array($query)) {
		$value['dateline'] = date('Y-m-d H:i',$value['dateline']);
		$info[] = $value;
	}
}

//分页
$perpage = 8;
$perpage = mob_perpage($perpage);
$page = empty($_GET['page'])?0:intval($_GET['page']);
if($page<1) $page = 1;
$start = ($page-1)*$perpage;

$wheresql = '';
if($_GET['view'] == "my"){
	$wheresql = " and uid=".$_SGLOBAL['supe_uid'];
}

//检查开始数
ckstart($start, $perpage);

if($_GET['fc'] == 'jobring') {


	//船员求职列表
	$list = array();
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('boatman')." WHERE status=1 ".$wheresql." ORDER BY dateline DESC LIMIT $start,$perpage");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$list[] = $value;
	}

	$count = getcount('boatman', array('status'=>1));
	$multi = multi($count, $perpage, $page, "space.php?do=hr&fc=jobring");

	$actives = array('jobring'=>' class="active"');
	$view = 'jb';

} elseif($_GET['fc'] == 'jobwant') {

	//船员求职列表
	$list = array();
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('boatman')." WHERE status=2 ".$wheresql." ORDER BY dateline DESC LIMIT $start,$perpage");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$list[] = $value;
	}

	$count = getcount('boatman', array('status'=>2));
	$multi = multi($count, $perpage, $page, "space.php?do=hr&fc=jobwant");

	$actives = array('jobwant'=>' class="active"');
	$view = 'jw';

} elseif($_GET['fc'] == 'hrbring') {

	//船员求职列表
	$list = array();
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('hrbring')." WHERE status=1 ".$wheresql." ORDER BY dateline DESC LIMIT $start,$perpage");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$list[] = $value;
	}

	$count = getcount('hrbring', array('status'=>1));
	$multi = multi($count, $perpage, $page, "space.php?do=hr&fc=hrbring");
	$actives = array('hrbring'=>' class="active"');
	$view = 'hb';

} elseif($_GET['fc'] == 'hrwanted') {

	//船员求职列表
	$list = array();
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('hrbring')." WHERE status=2 ".$wheresql." ORDER BY dateline DESC LIMIT $start,$perpage");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$list[] = $value;
	}

	$count = getcount('hrbring', array('status'=>2));
	$multi = multi($count, $perpage, $page, "space.php?do=hr&fc=hrwanted");
	$actives = array('hrwanted'=>' class="active"');
	$view = 'hw';

} elseif($_GET['fc'] == 'jb') {

	include_once(S_ROOT.'./source/function_hr.php');
	if($id<1){
		showmessage('do_success','space.php?do=hr&fc=jobring',0);
	}
	
	$hr = gethr('boatman', array('id'=>$id,'status'=>'1'));

	$sql = "SELECT * FROM ".tname('track')." where uid = ".$hr['uid']." order by dateline desc";
	$query = $_SGLOBAL['db']->query($sql);
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$track[] = $value;
	}
	
	$actives = array('jobring'=>' class="active"');

	include_once template("space_hr_view");
	exit();

} elseif($_GET['fc'] == 'jw') {

	include_once(S_ROOT.'./source/function_hr.php');
	if($id<1){
		showmessage('do_success','space.php?do=hr&fc=jobwant',0);
	}

	$hr = gethr('boatman', array('id'=>$id,'status'=>'2'));
	$sql = "SELECT * FROM ".tname('track')." where uid = ".$hr['uid']." order by dateline desc";
	$query = $_SGLOBAL['db']->query($sql);
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$track[] = $value;
	}
	$actives = array('jobwant'=>' class="active"');
	include_once template("space_hr_view");
	exit();
} elseif($_GET['fc'] == 'hb') {

	include_once(S_ROOT.'./source/function_hr.php');
	if($id<1){
		showmessage('do_success','space.php?do=hr&fc=hrbring',0);
	}

	$hr = gethr('hrbring', array('id'=>$id,'status'=>'1'));
	$sql = "SELECT * FROM ".tname('track')." where uid = ".$hr['uid']." order by dateline desc";
	$query = $_SGLOBAL['db']->query($sql);
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$track[] = $value;
	}
	$actives = array('hrbring'=>' class="active"');
	include_once template("space_hr_view");
	exit();
} elseif($_GET['fc'] == 'hw') {

	include_once(S_ROOT.'./source/function_hr.php');
	if($id<1){
		showmessage('do_success','space.php?do=hr&fc=hrwangted',0);
	}

	$hr = gethr('hrbring', array('id'=>$id,'status'=>'2'));
	$sql = "SELECT * FROM ".tname('track')." where uid = ".$hr['uid']." order by dateline desc";
	$query = $_SGLOBAL['db']->query($sql);
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$track[] = $value;
	}
	$actives = array('hrwanted'=>' class="active"');
	include_once template("space_hr_view");
	exit();
}

include_once template("space_hr");

?>